package com.woniuxy.intellihome.entity;

/**
 * 统一响应
 *
 */
public class ResponseEntity<T> {
    private int code; // 响应码
    private String msg; // 可选的描述信息
    private T data;// 可选，响应数据

    public ResponseEntity() {

    }

    public ResponseEntity(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public ResponseEntity(T data) {
        this(ResponseState.SUCCESS, "ok");
        this.data = data;
    }

    public final static ResponseEntity<Void> SUCCESS = new ResponseEntity<>(ResponseState.SUCCESS, "ok");
    public final static ResponseEntity<Void> FIAL = new ResponseEntity<>(ResponseState.FAIL, "ok");
    public final static ResponseEntity<Void> INVALIDARGS = new ResponseEntity<>(ResponseState.INVALIDARGS, "ok");

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
